/**
 *	实验二
 *	阅读下面程序，叙述其功能
 */
import java.io.FileReader;
import java.io.IOException;

public class T5E02 {

	public static void main(String[] args) {
		System.out.println("Please enter the file path:");
		try {
			String fileName = "";
			while(true) {
				int readByte = System.in.read();
				if(readByte == -1 || readByte == '\r')
					break;
				fileName += (char) readByte;
			}
			// Reads the file and prints it to the System.out stream.
			char[] buffer = new char[20];
			FileReader reader = new FileReader(fileName);
			while(true) {
				int length = reader.read(buffer);
				if(length < 0) // Reads a long as there is more data.
					break;
				String text = new String(buffer, 0, length);
				System.out.print(text);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}